
function tdg_highlight() {
    document.getElementById("run").disabled = true;
    if(document.getElementsByClassName('input').length > 0){
        var datas = $("#data").val();
        var fields = $("#field").val();
        save_left_data = datas;
        save_right_data = fields;

        var new_list = [];
        var words_json_list = [];
        var color_json = {};
        var list = trimSpace(fields.split("\n"));
        list.forEach(element => {
            var word = element.replace(/\s*/g, "");
            if(word.indexOf(".") > 0){
                var nword = word.split(".")[1];
                var header = word.split(".")[0];
                new_list.push([header, nword]);
            }else{
                new_list.push(["", word])
            };
        });


        new_list.forEach(item =>{
            var count = calc_count(datas, item);
            if(color_json.hasOwnProperty(item[1])){
                words_json_list.push({"color": color_json[item[1]], words:[item[1], count, item[0]]});
            }else{
                var sty = getRandomColor_count(item[1], count, item[0]);
                color_json[item[1]] = sty['color'];
                words_json_list.push(sty);
            };

        });
        Mark_simple_left(words_json_list, true);

        var base = '<div class="input" name="message" id="list" contenteditable="false"></div>';
        $("#mydiv2").append(base);

        //右边从新定义新的展示样式
        var num = 0.6;
        words_json_list.forEach(params =>{
            if(params["words"][1] == 0){

                var htmls = '<li class="item"><label><input class="hidden" type="checkbox"><span class="count" id="'+ params["color"] +'"' + ' style="background-color:' + "white" + ';border-color: '+ "black" + ';"' + '>' + params["words"][1] +
                    '</span><span>' + params["words"][2] + '.</span><span class="word" id="' + params["color"] + ';border-color: black">' + params["words"][0] + '</span></label></li>'
            }else{
                var htmls = '<li class="item"><label><input class="hidden" type="checkbox"><span class="count" id="'+ params["color"] +'"' + ' style="background-color:' + params["color"] + ';border-color: '+ params["color"] + ';"' + '>' + params["words"][1] +
                    '</span><span>' + params["words"][2] + '.</span><span class="word" id="' + params["color"] + '" style="background-color:' + params["color"] + ';border-color: '+ params["color"] + '">'
                    + params["words"][0] + '</span></label></li>'
            }
            $("#list").append(htmls);
        });

        $("#all-div").find("textarea[class='input']").remove();
        $("div[class='highlightTextarea-highlighter']").removeAttr('style');


    }

    $("#mydiv2 #list .item input").on('click', function (event) {
        if(event.target){
            var name = event.target.className;
            if(name == "word" || name == "hidden" || name == "count"){
                //右边元素定位
                var color_left = event.target.parentNode.childNodes[3].style.backgroundColor;
                var color = hex_color(color_left);
                var id_color = event.target.parentNode.childNodes[3].id;

                var all = $("[id='" + id_color + "']").each(function (j, items) {
                    if(color == id_color){
                        items.style.backgroundColor = "#00000000";

                    }else{
                        items.style.backgroundColor = id_color;
                    }
                });
            }
        }

    });

}